"""
测试程序模板
"""
import sys

from PyQt5 import QtWidgets  # pylint: disable=W0611
from PyQt5 import QtCore  # pylint: disable=W0611
from PyQt5 import QtGui  # pylint: disable=W0611


class QTreeWidgetTest(QtWidgets.QWidget):
    """
    测试主窗口
    """

    def __init__(self, parent=None):
        super(QTreeWidgetTest, self).__init__(parent)

        self.setWindowTitle("QTreeWidgetTest例子")

        self.listwidget = QtWidgets.QListWidget()
        self.listwidget.resize(300, 120)
        for i in range(1, 5):
            self.listwidget.addItem("Item %d" % (i))

        self.listwidget.setCurrentRow(0)
        self.listwidget.itemDoubleClicked.connect(self.list_item_dclicked)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.listwidget)
        self.setLayout(vbox)

    def list_item_dclicked(self, item):
        """双击选中一个条目"""
        print("select item : ", item.text())


if __name__ == '__main__':
    APP = QtWidgets.QApplication(sys.argv)
    QtWidgets.QApplication.setStyle("Fusion")
    WIN = QTreeWidgetTest()
    WIN.show()
    sys.exit(APP.exec_())
